class OrderDetail:
    def __init__(self, order_detail_id=None, order_id=None, food_id=None, quantity=None, unit_price=None, subtotal=None):
        self.order_detail_id = order_detail_id
        self.order_id = order_id
        self.food_id = food_id
        self.quantity = quantity
        self.unit_price = unit_price
        self.subtotal = subtotal
    
    def to_dict(self):
        return {
            'order_detail_id': self.order_detail_id,
            'order_id': self.order_id,
            'food_id': self.food_id,
            'quantity': self.quantity,
            'unit_price': self.unit_price,
            'subtotal': self.subtotal
        }
    
    @classmethod
    def from_dict(cls, data):
        return cls(
            order_detail_id=data.get('order_detail_id'),
            order_id=data.get('order_id'),
            food_id=data.get('food_id'),
            quantity=data.get('quantity'),
            unit_price=data.get('unit_price'),
            subtotal=data.get('subtotal')
        )